package com.findyou.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

/**
 * @Title: MvcConfig
 * @Author 贾金博
 * @Package com.findyou.config
 * @Date 2024/3/3 15:02
 * @description: 项目的配置类
 */

@EnableWebMvc // 配置了json转化器
/**
 * @EnableWebMvc的注解 也就是json处理器 给前端
 */
@Configuration // 配置类
@ComponentScan("com.findyou.returnJson")
public class MvcConfig implements WebMvcConfigurer {

    @Bean
    public RequestMappingHandlerMapping handlerMapping() {
        return  new RequestMappingHandlerMapping();
    }

    @Bean
    public RequestMappingHandlerAdapter handlerAdapter() {
        return new RequestMappingHandlerAdapter();
    }
    /**
     * 配置视图解析器
     * @param registry
     */
    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
       // WebMvcConfigurer.super.configureViewResolvers(registry);
        registry.jsp("/WEB-INF/views/", ".jsp");
    }
}
